using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace ClientTools.Server.Controls
{
    public partial class installer : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string sql1 = "SELECT COUNT(*) FROM umbracoAppTree WHERE treeAlias = 'ClientTools'";
            string sql2 = "INSERT INTO umbracoAppTree "
                + "(treeSilent, treeInitialize, treeSortOrder, appAlias, treeAlias, treeTitle, treeIconClosed, treeIconOpen, treeHandlerAssembly, treeHandlerType) "
                + " VALUES "
                + " (0, 1, 100, 'developer', 'ClientTools', 'Client Tools', 'folder.gif', 'folder_o.gif', 'ClientTools.Server.Controls', 'TreeHandler')";

            System.Data.SqlClient.SqlConnection con = new System.Data.SqlClient.SqlConnection(umbraco.GlobalSettings.DbDSN);
            con.Open();
            System.Data.SqlClient.SqlCommand com = new System.Data.SqlClient.SqlCommand(sql1, con);
            if (((int)com.ExecuteScalar()) == 0)
            {
                com = new System.Data.SqlClient.SqlCommand(sql2, con);
                com.ExecuteNonQuery();
            }
            this.Label1.Text = "<p>Client Tools for umbraco installed...</p>";
        }
    }
}